<?php
$mesg="回复该留言";
require_once 'validate.php';

session_start();
$uname=$_SESSION['uname'];

if(isset($_GET['postid'])){
if(isset($_POST['submit'])){
require_once 'dbconn.php';
$rmsg=$_POST['rcontent'];
$postid=$_GET['postid'];
date_default_timezone_set('PRC');
$rtime=date("Y-n-d H:i:s");
$query="insert into reply(uname,postid,rmsg,rtime) values('$uname',$postid,'$rmsg','$rtime')";
$result=$db->sql_query($query);
$sql= "update post set replies=replies+1 where postid=$postid";
$db->sql_query($sql);
 if ($result)
        $mesg="回复成功！<a href='msgboard.php'>请点击此处返回留言板!</a>";
}
}
else
echo "<script>location.href='msgboard.php'</script>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IBM俱乐部留言回复</title>
<link href="css/twoColFixLtHdr.css" rel="stylesheet" type="text/css" />
</head>
<body class="twoColFixLtHdr">
<div id="logo"></div>
<div id="navi"><table border="0" cellpadding="0" cellspacing="0"><tr>
<?php
require_once 'dbconn.php';
$sql="select * from module";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrowset($result);
require_once 'resource_list.php';
foreach($row as $arr)
{
$modname=$arr['modname'];
$modhref=$arr['modhref'];
navi_list($modname,$modhref);
}
?>
</tr></table>
</div>
<div id="container">
<br /><h1><?php echo $mesg;?></h1>
<hr size="5" color="#9D9D9D" />
<hr size="5" color="#9D9D9D" />
</div>
<div id="container">

<table width="960"  cellpadding="0" cellspacing="0" border="0" id="table_msgboard">
<tr><th height="40" style="text-align:center;"><?php echo $uname;?>你好！&nbsp;&nbsp;
<input type="button" value="返回留言板" onclick="window.location.reload('msgboard.php');"/></th></tr>
<tr height="500"><td>

<table cellpadding="0" cellspacing="0" id="table_msg">
<?php 
require_once 'dbconn.php';
$postid=$_GET['postid'];
$sql="select * from post where postid=".$postid;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
require_once 'reply_post.php';
$uname=$row['uname'];
$ptitle=$row['ptitle'];
$msg=$row['msg'];
$ptime=$row['ptime'];
$replies=$row['replies'];
reply_alpost($uname,$ptitle,$msg,$ptime,$replies);
?>

<tr><form action="" method="post" name="msg"><th colspan="2" style="text-align:center; vertical-align:top;"><br /><br />
<textarea cols="80" rows="12" name="rcontent"></textarea><br />
<input type="submit" name="submit" value="发表留言" /><br /><br /></th></form></tr>
</table><br />

</td></tr>
</table>
</div>
<div id="footer">
<p>Copyright © 2010 IBM club,Shenzhen University, All Rights Reserved.</p></div>
</div>
</body>
</html>
